<!--点击提交问题显示问题的展示区域(插入的过程)-->
var showQuestion = function(){
    var ajaxFormOptions = {
        url          : WebSite.CommitPage.commitQuestion,
        type         : "post",
        dataType     : "json",
        beforeSubmit : function(){
            WebSite.debug(WebSite.CommitPage.commitQuestion);
            if($("#name").val().trim() == ""){
                alert("问题的标题不能为空");
                return false;
            }
            if($("#contentEditor").text().trim() == ""){
                alert("问题的描述不能为空");
                return false;
            }
        },
        success : function(result){
            if(result.success){
                $(".show").show();
                $(".context").hide();
                  var pk_question = result.resultData.pk_sool_question;
                //      alert(pk_question);
                $("#showQuestionTitle").data("pk_question",pk_question);
                $("#showQuestionTitle").html(result.resultData.question_title);
                $("#showQuestionContext").html(result.resultData.description);
                $("#oldfilenamesuccess").html('<a href='+result.resultData.new_file_url+'>'+result.resultData.old_fileName+'</a>');
                $("#old_fileName").val(selectQuestion_data.old_fileName);
                $("#new_file_url").val(selectQuestion_data.new_file_url);
            }else{
                if(result.statusCode=='001'){
                    $("#covered").show();
                    $("#poplayer").show();
                
                }else{
                    alert(result.msg);
                }
            }


        },
        error : function(){
            alert("提交问题未成功");
        }
    };

    $("#context_editor").ajaxForm(ajaxFormOptions);
};

/*点击修改信息按钮提交数据*/
var updataUserInfo = function(){

    $.ajax({
        url          : WebSite.CommitPage.submitUserInfo,
        type         : "post",
        data         : {"username" : $("#user-name").val().trim(),
                        "mobile" : $("#user-phone").val().trim(),
                        "email" : $("#user-email").val().trim()
                        },
        dataType     : "json",
        success      : function(result){
            if(result.success){
                $("#poplayer").hide();
                $("#covered").hide();
                submitQuestion();
            }else{
                alert(result.msg);
            }
        },
        error        : function(){
            alert("提交用户信息不成功");
        }
    });
};

<!--点击修改问题隐藏文字并显示到编辑区域-->
var clickUpdataQuestion = function(){
    $(".show").on("click","#updateQuestion",function(){
        var pk_question = $("#showQuestionTitle").data("pk_question");
       // alert(pk_question);
        selectQuestion(pk_question);
        otherUpdateQuestion(pk_question);
    });
};

/*更新问题*/
var otherUpdateQuestion = function(pk_question){
    var ajaxFormOptions = {
        url          : WebSite.CommitPage.updateQuestion,
        type         : "post",
        data         : {"pk_sool_question" : pk_question},
        dataType     : "json",
        beforeSubmit : function(){
            if($("#name").val().trim() == ""){
                alert("问题的标题不能为空");
                return false;
            }
            if($("#contentEditor").html().trim() == ""){
                alert("问题的描述不能为空");
                return false;
            }
        },
        success : function(result){
            if(result.success){
              //  WebSite.debug("更新问题正在执行");
                $(".show").show();
                $(".context").hide();
                $("#showQuestionTitle").html(result.resultData.question_title);
                $("#showQuestionTitle").data("pk_question",pk_question);
             //   WebSite.debug("更新方法的描述是"+result.resultData.description);
                $("#showQuestionContext").html(result.resultData.description);
                $("#oldfilenamesuccess").html('<a href="'+result.resultData.new_file_url+'">'+result.resultData.old_fileName+'</a>');
                $("#old_fileName").val(selectQuestion_data.old_fileName);
                $("#new_file_url").val(selectQuestion_data.new_file_url);
                //
 		    }else{
                	alert(result.msg);
            	}
            },
        error : function(){
            alert("更新问题失败");
        }

    };

    $("#context_editor").ajaxForm(ajaxFormOptions);

};

/*查询问题*/
var selectQuestion = function(pk_question){
    $.ajax({
        url : WebSite.CommitPage.selectQuestion,
        type : "post",
        data : {"pk_sool_question": pk_question},
        dataType : "json",
        success : function(result){
            if(result.success){
                WebSite.debug("查询方法正在执行");
                var selectQuestion_data = result.resultData;
                WebSite.debug("查询方法的question_title"+selectQuestion_data.question_title);
                $(".show").hide();
                $(".context").show();
                $("#name").val(selectQuestion_data.question_title);
                $("#contentEditor").html(selectQuestion_data.description);
                $("#oldfilename").html('<a href="'+selectQuestion_data.new_file_url+'">'+selectQuestion_data.old_fileName+'</a>');
                $("#old_fileName").val(selectQuestion_data.old_fileName);
                $("#new_file_url").val(selectQuestion_data.new_file_url);
            }
        },
        error : function(){
            alert("没有查询获得数据");
        }
    });
};

/*验证问题的标题不能超过25个字*/
var title_length = function(){
    /*var title_length = $("#name").val().trim();
     if(title_length.length > 3){
     $(".showMessage").show();
     }*/
    var text1=document.getElementById("name").value;
    var len;//记录剩余字符串的长度
    if(text1.length>=25) //限制字数
    {
        document.getElementById("name").value=text1.substr(0,25);
        len=0;
    }
    else
    {
        len=25-text1.length;  //限制字数
    }
    var show="您还可以输入"+len+"个字";
    document.getElementById("showMessage").innerText=show;
}



/*点击完保存用户信息后提交问题信息*/
var submitQuestion = function(){
    var question_title = $("#name").val().trim();
    var description = $("#contentEditor").html().trim();
    $.ajax({
        url          : WebSite.CommitPage.commitQuestion,
        type         : "post",
        dataType     : "json",
        data : {"question_title": question_title,"description":description},
        success : function(result){
            if(result.success){
                $(".show").show();
                $(".context").hide();
                var pk_question = result.resultData.pk_sool_question;
                $("#showQuestionTitle").data("pk_question",pk_question);
                $("#showQuestionTitle").html(result.resultData.question_title);
                $("#showQuestionContext").html(result.resultData.description);
            }else{
                if(result.statusCode=='001'){
                    $("#covered").show();
                    $("#poplayer").show();

                }else{
                    alert(result.msg);
                }
            }


        },
        error : function(){
            alert("提交问题未成功");
        }

    });
}

